package com.zhdl.common.ytools.eventbus.center;

import com.google.common.eventbus.AsyncEventBus;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class EventBusCenter {

    private static AsyncEventBus asyncEventBus;
    private static final Executor executor = Executors.newFixedThreadPool(10);

    //双重锁单例模式
    public static AsyncEventBus getEventBus() {
        if (asyncEventBus == null) {
            synchronized (AsyncEventBus.class) {
                if (asyncEventBus == null) {
                    asyncEventBus = new AsyncEventBus(executor);
                }
            }
        }
        return asyncEventBus;
    }

}